<?php
/**
 * Created by PhpStorm.
 * User: fenfen
 * Date: 2017/1/3
 * Time: 17:51
 */

namespace bc\model;

use bc\ar\MActiveRecord;
class ReporttitleModel extends MActiveRecord
{
    public static function tableName()
    {
        return '{{%report_title}}';
    }

    public function getInfoFromProductId($product_id)
    {
        if(empty($product_id)){
            return array();
        }

        $where=array(
            'bc_report_title.product_id'=>$product_id,
            'bc_report_title.deleted'=>0
        );

        $this->columns="report_key,report_value";
        $ar=$this->find ()->select( $this->columns )->where($where);
        $ar->createCommand()->getRawSql();
        $infoList= $ar->asArray ()->all ();
        foreach($infoList as $k => $value){
            $data[$value['report_key']]=$value['report_value'];
        }
        return $data;
    }
}